//
//  PackageView.m
//  penzer
//
//  Created by 还带大道 on 2018/11/5.
//  Copyright © 2018年 caiyc. All rights reserved.
//

#import "PackageView.h"

@interface PackageView()

@end

@implementation PackageView

- (instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame]){
        
        //imageV
        UIImageView *imageV = [[UIImageView alloc] init];
        _imageV = imageV;
        imageV.image = [UIImage imageNamed:@"icon_cz_nomal"];
        imageV.tag = 101;
        [self addSubview:imageV];
        [imageV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.bottom.equalTo(self);
        }];
        
        UILabel *label1 = [[UILabel alloc] init];
        _label1 = label1;
        label1.text = @"套餐1";
        label1.tag = 102;
        label1.textColor = [UIColor whiteColor];
       // label1.textColor = RZ_COLOR(255, 250, 206);
        label1.font = [UIFont systemFontOfSize:11];
        [self addSubview:label1];
        [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(10);
            make.centerX.equalTo(self);
        }];
        
        UILabel *label2 = [[UILabel alloc] init];
        _label2 = label2;
        label2.text = @"100次机会";
        label2.tag = 103;
        label2.textColor = [UIColor whiteColor];
        label2.font = [UIFont systemFontOfSize:14];
        [self addSubview:label2];
        [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(label1.mas_bottom).offset(5);
            make.centerX.equalTo(self);
        }];
        
        UILabel *label3 = [[UILabel alloc] init];
        _label3 = label3;
        label3.text = @"￥20";
        label3.tag = 104;
        label3.textColor = [UIColor whiteColor];
        label3.font = [UIFont systemFontOfSize:20];
        [self addSubview:label3];
        [label3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(label2.mas_bottom).offset(5);
            make.centerX.equalTo(self);
        }];
        
        UIButton *btn = [UIButton new];
        _btn = btn;
        [self addSubview:btn];
        [btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.top.equalTo(self);
        }];
        [btn addTarget:self action:@selector(onClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return self;
}




-(void)bindData:(NSDictionary *)data{
    UIImageView *images = (UIImageView *)[self viewWithTag:101];
    UILabel *name = (UILabel *)[self viewWithTag:102];
    UILabel *nums = (UILabel *)[self viewWithTag:103];
    UILabel *price = (UILabel *)[self viewWithTag:104];
    name.text = data[@"title"];
    nums.text = data[@"description"];
    price.text = [NSString stringWithFormat:@"¥%@", data[@"price"]];
    self.snpackageid = [NSString stringWithFormat:@"%@",data[@"id"]];
    self.price = data[@"price"];
}



- (void)onClick
{
    !self.onClickBlock?:self.onClickBlock(self);
}


@end
